<?php
// +----------------------------------------------------------------------
// | Author: yaoyihong <510974211@qq.com>
// +----------------------------------------------------------------------
namespace addon\wechat_config\model;
use \think\Request;
use app\common\model\AddonBase;
use Think\Db;
class User extends AddonBase
{
    protected $insert = ['create_time','last_login_time'];
    protected $update = ['last_login_time','last_login_ip'];

    protected function setCreateTimeAttr(){
        return time();
    }

    protected function setLastLoginIpAttr(){
        return request()->ip();
    }

    protected function setNicknameAttr($value){
        if(empty($value)){
            return "tpframe_".rand(100,99999);
        }
        return $value;
    }

    protected function setPasswordAttr($value){
        return '###'.md5($value.DATA_ENCRYPT_KEY);
    }

    protected function setLastLoginTimeAttr(){
        return time();
    }
}
